#ifndef SENDRECEIVECONTROLL_H
#define SENDRECEIVECONTROLL_H

#include <QDialog>
#include <QtNetwork>

class sendReceiveControll: public QObject
{
    Q_OBJECT

private:
    QUdpSocket *dataSocket;
    QUdpSocket *broadcastSocket;
    QUdpSocket *senderSocket;
    QUdpSocket *initSocket;

    QByteArray datagram;
    QHostAddress senderIp;
    quint16 senderPort;

public:

    //Konstruktor
    sendReceiveControll();
    ~sendReceiveControll();


    void sendBroadcast(QByteArray datagram);
    void sendData(QHostAddress targetIP,
                  quint16 port,
                  QByteArray data);
    //getter
    QHostAddress getSenderIP();
    quint16 getSenderPort();
    QByteArray getDatagram();

signals:
    void dataReadyRead(QHostAddress senderIp,
                       quint16 senderPort,
                       QByteArray datagram);
    void broadcastReadyRead(QHostAddress senderIp,
                            quint16 senderPort,
                            QByteArray datagram);

private slots:
    void receivedData();
    void receivedBroadcast();
};

#endif // SENDRECEIVECONTROLL_H
